package com.anti.modular.bus.roomreservation.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.roomreservation.param.RoomReservationParam;
import com.anti.modular.bus.roomreservation.service.RoomReservationService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 房间预定控制器
 *
 * @author anti
 * @date 2021-04-23 09:43:48
 */
@RestController
@RequestMapping("roomReservation")
public class RoomReservationController {

    @Resource
    private RoomReservationService roomReservationService;

    /**
     * 查询房间预定
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @GetMapping("page")
    @BusinessLog(title = "房间预定_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam, RoomReservationParam roomReservationParam) {
        return Result.data(roomReservationService.page(pageParam,roomReservationParam));
    }

    /**
     * 添加房间预定
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "房间预定_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(RoomReservationParam.add.class) RoomReservationParam roomReservationParam) {
            roomReservationService.add(roomReservationParam);
        return Result.success("新增成功");
    }

    /**
     * 删除房间预定
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "房间预定_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(RoomReservationParam.delete.class) RoomReservationParam roomReservationParam) {
            roomReservationService.delete(roomReservationParam);
        return Result.success("删除成功");
    }
    @Permission
    @PostMapping("deleteAllSelect")
    @BusinessLog(title = "房间预定_批量删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result deleteAllSelect(@RequestBody List<Long> roomReservationParam) {
        roomReservationService.deleteAllSelect(roomReservationParam);
        return Result.success("删除成功");
    }
    /**
     * 编辑房间预定
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "房间预定_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(RoomReservationParam.edit.class) RoomReservationParam roomReservationParam) {
            roomReservationService.edit(roomReservationParam);
        return Result.success("修改成功");
    }

    /**
     * 查看房间预定
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @GetMapping("detail")
    @BusinessLog(title = "房间预定_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public Result detail(@Validated(RoomReservationParam.detail.class) RoomReservationParam roomReservationParam) {
        return Result.data(roomReservationService.detail(roomReservationParam));
    }

    /**
     * 房间预定列表
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @GetMapping("list")
    @BusinessLog(title = "房间预定_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result list(RoomReservationParam roomReservationParam) {
        return Result.data(roomReservationService.list(roomReservationParam));
    }
    /**
     * 编辑房间预定
     *
     * @author anti
     * @date 2021-04-23 09:43:48
     */
    @Permission
    @PostMapping("qxyd")
    @BusinessLog(title = "房间取消预定_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result qxyd(@RequestBody RoomReservationParam roomReservationParam) {
        roomReservationService.editQxyd(roomReservationParam);
        return Result.success("修改成功");
    }
}
